#ifndef VERTICALLAYOUTPANELCONTAINERFACTORY_H
#define VERTICALLAYOUTPANELCONTAINERFACTORY_H

#include <QFrame>
#include <QVBoxLayout>

#include <pluginui/manager/AbstractPanelContainerFactory.h>

namespace antu
{
namespace plugin
{
namespace ui
{
class VerticalLayoutPanelContainer : public AbstractPanelContainer
{
    Q_OBJECT

public:
    VerticalLayoutPanelContainer(const QString& name, const QString& title,
                      Qt::DockWidgetArea area = Qt::NoDockWidgetArea,
                      Qt::DockWidgetAreas allowedAreas = Qt::LeftDockWidgetArea |
                                                         Qt::RightDockWidgetArea |
                                                         Qt::BottomDockWidgetArea,
                      QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable |
                                                                 QDockWidget::DockWidgetFloatable |
                                                                 QDockWidget::DockWidgetMovable)
        : AbstractPanelContainer(name, area, allowedAreas, features)
    {
        this->m_pWidget = new QWidget;
        this->m_pWidget->setContentsMargins(0, 0, 0, 0);
        this->m_pWidget->setWindowTitle(title);
        this->m_pWidget->setObjectName(name);
        m_pLayout = new QVBoxLayout;
        this->m_pWidget->setLayout(m_pLayout);
    }

    // AbstractPanelContainer interface
public:
    void addSeparator(QFrame::Shadow shadow)
    {
        QFrame* pSeparator = new QFrame(this->m_pWidget);
        pSeparator->setFrameShape(QFrame::HLine);
        pSeparator->setFrameShadow(shadow);
        this->m_pLayout->addWidget(pSeparator);
    }

    QWidget *containerWidget()
    {
        return this->m_pWidget;
    }

protected:
    void addToContainer(PanelItem *pPanelItem, int stretch)
    {
        Q_ASSERT(pPanelItem != nullptr);
        Q_ASSERT(pPanelItem->widget() != nullptr);
        this->m_pLayout->addWidget(pPanelItem->widget(), stretch);
    }

    void doFinalize()
    {

    }

    QWidget* m_pWidget;
    QVBoxLayout* m_pLayout;

    // AbstractPanelContainer interface
public:
    virtual void setChangeWindowTitleWithTab(bool changeWithTab);
};

class VerticalLayoutPanelContainerFactory : public AbstractPanelContainerFactory
{
public:
    VerticalLayoutPanelContainerFactory();

    // AbstractPanelContainerFactory interface
public:
    AbstractPanelContainer *createContainer(const QString &name, const QString &title, Qt::DockWidgetArea area, Qt::DockWidgetAreas allowedAreas, QDockWidget::DockWidgetFeatures features);
};
}
}
}

#endif // VERTICALLAYOUTPANELCONTAINERFACTORY_H
